package org.example.blog.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.blog.model.BlogInfo;

import java.util.List;

@Mapper
public interface BlogMapper {
    //获取所有博客列表
    @Select("select * from blog where delete_flag = 0")
    List<BlogInfo> selectAll();


    /**
     * 根据博客ID, 返回博客信息
     * @return
     */
    @Select("select * from blog where id = #{id}")
    BlogInfo selectById(Integer id);

    //更新博客 xml写
    Integer updateBlog(BlogInfo blogInfo);

    //发布博客 执行插入操作
//    @Insert("insert into blog (title,content,user_id) values(#{title},#{content},#{userId})")
//    Integer insertBlog(BlogInfo blogInfo);
    @Insert("insert into blog (title, content, user_id) values (#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);

}
